Dim _INK(8),_TRY(13,5),USED(5),USED2(5),WHITES(12),BLACKS(12),DISPLAY_TEXT$(5)
Global _INK(),_TRY(),GUESS,_COLOUR,USED(),WHITES(),BLACKS(),USED2(),BUTTONS,_TEST$,DISPLAY_TEXT$(),LAST_TEXT,TEST_TEXT,RULES_SCROLL,DELAY,_START_COLOUR
INIT_VARIABLES
_STARTUP_INFO
_SETUP
_MAIN_LOOP
'
'
'
Procedure _MAIN_LOOP
Do
_GAME
Locate 22,18 : Print " ";
Put Block 5,0,0
CLEAR_GUESS
Loop
End Proc
'
Procedure _GAME
GUESS=13
Repeat : Until Inkey$=""
Pen 8
Locate 22,17
Print " Solution "
LAST_TEXT=5 : _TEXT$=""
_START_COLOUR=1 : _GET_COLOUR
_NEXT_GUESS
CLEAR_GUESS
LAST_TEXT=3
_START_COLOUR=1 : _GET_COLOUR
'
Repeat
Paper 0
Pen 8
Locate 22,17
Print " Guess";GUESS;" "
_NEXT_GUESS
If BUTTONS=0 and GUESS<12 and GUESS=>0
CLEAR_GUESS
_MARK
_STORE
End If
TEST=GUESS+1
If BLACKS(TEST)=5
FOUND_IN=0-GUESS+12 : GUESS=0
Locate 22,17
Paper 0
Pen 11
Print " Solved in";FOUND_IN
End If
Until GUESS<=0
_SHOW_SOLUTION
Locate 22,18
Pen 8
Paper 0
Print " Press any key "
Repeat
_GO=Mouse Click
If Inkey$<>"" Then _GO=1
Until _GO
Repeat
A$=Inkey$
Until A$=""
NEWGAME
End Proc
'
Procedure _NEXT_GUESS
Shared _TEXT$
Repeat
FULL=0
Repeat
If COUNTER=DELAY and RULES_SCROLL=1
If _TEXT$=""
TEST_TEXT=0
If LAST_TEXT=3
_TEXT$=DISPLAY_TEXT$(1) : LAST_TEXT=1
TEST_TEXT=1
End If
If LAST_TEXT=2
_TEXT$=DISPLAY_TEXT$(3) : LAST_TEXT=3
End If
If LAST_TEXT=1 and TEST_TEXT=0
_TEXT$=DISPLAY_TEXT$(2) : LAST_TEXT=2
End If
TEST_TEXT=0
If GUESS=13 and LAST_TEXT=4
_TEXT$=DISPLAY_TEXT$(5)
LAST_TEXT=5
TEST_TEXT=1
End If
If GUESS=13 and LAST_TEXT=5 and TEST_TEXT=0
_TEXT$=DISPLAY_TEXT$(4)
LAST_TEXT=4
End If
_TEXT$=" "+_TEXT$
End If
Locate 22,18
Paper 0
Pen 1
Print Left$(_TEXT$,17);
_TEXT$=Right$(_TEXT$,Len(_TEXT$)-1)
COUNTER=0
End If
Inc COUNTER
If COUNTER>DELAY Then COUNTER=0
If Inkey$<>"" and GUESS=13
For RANDOM_SOLUTION=1 To 5
_TRY(13,RANDOM_SOLUTION)=Rnd(7)+1
FULL=1
Next
End If
If GUESS=0 Then FULL=1
_MOVE_MOUSE
If Joy(1)=>16 Then _BUTTON_PRESSED=1
If _BUTTON_PRESSED=0 Then _BUTTON_PRESSED=Mouse Click
If FULL=0 Then Until _BUTTON_PRESSED=1
_BUTTON_PRESSED=0
If FULL=0 and GUESS>0
If Y Screen(Y Mouse)<151
Repeat
Until Mouse Click=0
BUTTON
BUTTONS=1
Else
BUTTONS=0
End If
If BUTTONS=0 and GUESS>0
If X Screen(X Mouse)<104
_GET_COLOUR
End If
If X Screen(X Mouse)>103
_SPOT
End If
FULL=True
For X=1 To 5
If _TRY(GUESS,X)=0
FULL=False
End If
Next
End If
If GUESS=0
FULL=1
End If
End If
Until FULL
If GUESS=13 Then _TEXT$=""
GUESS=GUESS-1
End Proc
'
Procedure _SPOT
X=(X Screen(X Mouse)-128)
Y=(Y Screen(Y Mouse)-178)
RADIAS=15 : SPOT_X=0 : SPOT=0
For _BOX=1 To 5
If X=<SPOT_X+RADIAS and Y=<RADIAS and X=>SPOT_X-RADIAS and Y=>-RADIAS
SPOT=_BOX
_BOX=5
End If
If SPOT=0 Then SPOT_X=SPOT_X+41
Next
If SPOT>0 and SPOT>0
If SPOT>0 and SPOT<6
Ink _INK(_COLOUR)
Paint(SPOT-1)*41+128,178
_TRY(GUESS,SPOT)=_COLOUR
End If
End If
End Proc
'
Procedure _SETUP
Break Off
Curs Off
Change Mouse 2
Show
Cls 0
Paper 0
Pen 1
Load Iff "mastermind.iff"
Get Block 5,0,0,320,136
Ink 3
Limit Mouse 130,186 To 446,247
Randomize Timer
End Proc
'
Procedure INIT_VARIABLES
_INK(1)=1
_INK(2)=14
_INK(3)=4
_INK(4)=12
_INK(5)=15
_INK(6)=6
_INK(7)=10
_INK(8)=13
GUESS=13
_COLOUR=1
Ink _INK(1)
DISPLAY_TEXT$(1)="Use the mouse to select a colour, and then the place where you want that colour peice. When you have filled all blank places i will store and mark your guess. "
DISPLAY_TEXT$(2)="Marking: White circle represent a correct colour peice but in the wrong place, and Black circle represent a correct colour in the correct place. These circles are found next to your guess on the board. "
DISPLAY_TEXT$(3)="The circles are not in any order. "
DISPLAY_TEXT$(4)="If you want a computer generated solution press any key or, Make sure that the person, who is going to attempt to guess the solution, can not see the screen at the moment. "
DISPLAY_TEXT$(5)="Select your colour, then put it in then place where you want it. When all places are filled i will hide your solution and wait for other player to put in their guesses. "
RULES_SCROLL=1
DELAY=61
End Proc
'
Procedure _GET_COLOUR
Shared _TEXT$,LAST_TEXT,_START_COLOUR
If _START_COLOUR=1 and Joy(1)=<16
Repeat
Break On
Until Joy(1)<16
End If
Break Off : Repeat : Until Joy(1)<16
Repeat
X_OFF=_COLOUR-1 : Y_OFF=0
If _COLOUR>4 Then Y_OFF=1 : X_OFF=_COLOUR-4-1
X_OFF=((X_OFF)*25)+3
Y_OFF=(Y_OFF*21)
Y_OFF=Y_OFF+157
If _COLOUR>0 and _COLOUR<>5 Then X_OFF=X_OFF-1
If _COLOUR=4 or _COLOUR=8 or _COLOUR=5 Then X_OFF=X_OFF-1
Ink 0
Box X_OFF-1,Y_OFF-1 To X_OFF+23,Y_OFF+19
Box X_OFF,Y_OFF To X_OFF+22,Y_OFF+18
If _START_COLOUR=0
Repeat
X=(X Screen(X Mouse)-1)/25
Y=(Y Screen(Y Mouse)-156)/21
If X>3
X=9
End If
_COLOUR=Y*4+X+1
If _COLOUR>0 and _COLOUR<9
Ink _INK(_COLOUR)
_COLOUR_SET=True
End If
Until _COLOUR_SET
End If
If _START_COLOUR=1 Then _COLOUR=1
X_OFF=_COLOUR-1 : Y_OFF=0
If _COLOUR>4 Then Y_OFF=1 : X_OFF=_COLOUR-4-1
X_OFF=((X_OFF)*25)+3
Y_OFF=(Y_OFF*21)
Y_OFF=Y_OFF+157
If _COLOUR>0 and _COLOUR<>5 Then X_OFF=X_OFF-1
If _COLOUR=4 or _COLOUR=8 or _COLOUR=5 Then X_OFF=X_OFF-1
Ink 1
Box X_OFF-1,Y_OFF-1 To X_OFF+23,Y_OFF+19
Box X_OFF,Y_OFF To X_OFF+22,Y_OFF+18
_START_COLOUR=0
Until Mouse Key=0
'
End Proc
'
Procedure CLEAR_GUESS
Ink 9
X=132 : Y=178
For Z=1 To 5
Paint X,Y
X=X+41
Next
Ink _INK(_COLOUR)
If GUESS=12 Then Ink _INK(1)
End Proc
'
Procedure _STORE
X_OFF=0
If GUESS=>6 Then X_OFF=166
X_OFF=X_OFF+13
Y_OFF=GUESS
If GUESS=>6 Then Y_OFF=GUESS-5
If GUESS<6 Then Y_OFF=Y_OFF+1
X=7
Repeat
X=X-1
Until X=Y_OFF
If X=0 Then X=1
Y_OFF=X*22-20+10
For RE=1 To 5
Ink _INK(_TRY(GUESS+1,RE))
Paint X_OFF,Y_OFF
X_OFF=X_OFF+20
Next
OLD_COLOUR=_COLOUR
Ink _INK(5)
If BLACKS(GUESS+1)>0
For _BLACK=1 To BLACKS(GUESS+1)
Paint X_OFF,Y_OFF
X_OFF=X_OFF+8
Next
End If
If WHITES(GUESS+1)>0
Ink _INK(1)
For _WHITE=1 To WHITES(GUESS+1)
Paint X_OFF,Y_OFF
X_OFF=X_OFF+8
Next
End If
Ink OLD_COLOUR
End Proc
'
Procedure _MARK
TEST=GUESS+1
BLACKS(TEST)=0
For ANSWER=1 To 5
USED(ANSWER)=0
USED2(ANSWER)=0
If _TRY(13,ANSWER)=_TRY(TEST,ANSWER)
BLACKS(TEST)=BLACKS(TEST)+1
USED2(ANSWER)=1
USED(ANSWER)=1
End If
Next
WHITES(TEST)=0
For ANSWER=1 To 5
For TRY=1 To 5
If TRY<>ANSWER
If USED(ANSWER)=0 and USED2(TRY)=0
If _TRY(13,ANSWER)=_TRY(TEST,TRY)
WHITES(TEST)=WHITES(TEST)+1
USED(ANSWER)=1
USED2(TRY)=1
End If
End If
End If
Next
Next
End Proc
'
Procedure BUTTON
Locate 0,0
X=X Screen(X Mouse)
If X<40 and X>2
QUIT
End If
If ANSWER=0 and X>40 and X<92
_RULES
End If
If X>92 and X<171 and GUESS<13 Then GUESS=0
ANSWER=0
End Proc
'
Procedure NEWGAME
For X=1 To 13
For Y=1 To 5
_TRY(X,Y)=0
Next
Next
End Proc
'
Procedure _SHOW_SOLUTION
Y_OFF=178
X_OFF=128
For X=1 To 5
Ink _INK(_TRY(13,X))
Paint X_OFF,Y_OFF
X_OFF=X_OFF+41
Next
End Proc
'
Procedure QUIT
Get Block 1,0,110,96,47
Ink 0
Bar 0,115 To 95,152
Ink 1
Box 0,115 To 95,152
Locate 1,15
Pen 1 : Paper 0
Print "Realy Quit"
Ink 1
Bar 5,134 To 34,144
Bar 68,134 To 89,144
Paper 1 : Pen 0
Locate 1,17 : Print "Yes"
Locate 9,17 : Print "No"
Repeat : Until Joy(1)<16 : Repeat
Repeat
_MOVE_MOUSE
If Joy(1)=>16 Then _BUTTON_PRESSED=1
If _BUTTON_PRESSED=0 Then _BUTTON_PRESSED=Mouse Click
If FULL=0 Then Until _BUTTON_PRESSED=1
_BUTTON_PRESSED=0
X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
If Y=>134 and Y=<144
If X=>5 and X<=34
If Exist("menu.amos")
Run "menu.amos"
End If
System
End If
If X=>68 and X<=89
ANSWER=1
End If
End If
Until ANSWER
Put Block 1,0,110 : Repeat : Until Joy(1)<16
End Proc
'
Procedure _RULES
Get Block 2,10,119,112,55
Ink 0
Bar 11,119 To 117,171
Ink 1
Box 11,119 To 117,171
Paper 0 : Pen 1
Locate 2,15 : Print "Rules Scroll"
Locate 2,16 : Print " Delay"
Paper 0 : Pen 1
Locate 3,17 : Print " - ";
Locate 10,17 : Print " + ";
Paper 1 : Pen 0
Locate 3,20 : Print " On ";
Locate 8,20 : Print " Off "
DELAY$=Str$(DELAY/10)
DELAY$=Right$(DELAY$,Len(DELAY$)-1)
Locate 6,17
Pen 8 : Paper 0
If DELAY/10<10 Then Print " ";
If DELAY/10<100 Then Print " ";
If DELAY/10<1000 Then Print " ";
Print DELAY$;
Box 23,159 To 56,168
Box 63,159 To 104,168
Box 23,135 To 104,144
_DONE=0
Repeat
Repeat
_MOVE_MOUSE
If Joy(1)=>16 Then _BUTTON_PRESSED=1
If _BUTTON_PRESSED=0 Then _BUTTON_PRESSED=Mouse Click
If FULL=0 Then Until _BUTTON_PRESSED=1
_BUTTON_PRESSED=0
X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
If X>23 and X<56 and Y>159 and Y<168
RULES_SCROLL=1
_DONE=1
End If
If X>63 and X<104 and Y>159 and Y<168
RULES_SCROLL=0
_DONE=1
End If
While Mouse Key=1 or Joy(1)=>16
X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
If X>23 and X<48 and Y>135 and Y<144
If DELAY>10
DELAY=DELAY-10
Pen 0 : Paper 1
Locate 3,17 : Print " - ";
End If
End If
If X>79 and X<104 and Y>135 and Y<144
If DELAY/10<1000
DELAY=DELAY+10
Pen 0 : Paper 1
Locate 10,17 : Print " + ";
End If
End If
DELAY$=Str$(DELAY/10)
DELAY$=Right$(DELAY$,Len(DELAY$)-1)
Locate 6,17
Paper 0 : Pen 8
If DELAY/10<10 Then Print " ";
If DELAY/10<100 Then Print " ";
If DELAY/10<1000 Then Print " ";
Print DELAY$;
Wait 5
Wend
Paper 0 : Pen 1
Locate 3,17 : Print " - ";
Locate 10,17 : Print " + ";
Until _DONE
Put Block 2,10,119
If RULES_SCROLL=0
Locate 22,18
Pen 1 : Paper 0
Print " ";
End If : Repeat : Until Joy(1)<16
End Proc
'
Procedure _STARTUP_INFO
Hide
Curs Off
Cls 0
Paper 0
A$=" Welcome To FoxWare's Master Mind. Press any key or mouse buton to continue. Other FoxWare Products: Othello Solitaire Monopoly. FoxWare:- Paul Fox 102 Wrigley St. Maroochydore Qld. 4558"